<%@page import="com.dfhc.base.price.IPriceConstants" %>
<%@page import="org.quickbundle.tools.helper.RmJspHelper" %>
<%@page import="org.quickbundle.project.RmGlobalReference" %>
<%@page import="com.dfhc.ISystemConstant" %>
<%@ page contentType="text/html; charset=UTF-8" language="java"%>

<!DOCTYPE html>
<html lang="en">
	<head>
	
	<!-- 全局js 和css包 -->
	<%@ include file="/jsp/include/web/jqGrid/global.jsp" %>
	<meta charset="utf-8" />
	<title><bean:message key="qb.web_title"/></title>

	<meta name="description" content="Dynamic tables and grids using jqGrid plugin" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />

	<style type="text/css">
				/*遮罩层*/
		.outer-div{  
		    position: fixed;  
		    top: 0;  
		    left: 0;  
		    width: 100%;  
		    height: 100%;  
		    background: #000;  
		    opacity: 0.5;  
		    filter:alpha(opacity=50);  
		    display: none !important;  
		    z-index: 10000;
		}  
		.inner-div{  
		    position: absolute;  
		    top: 10%;  
		    left: 10%;  
		    width: 80%; 
		    min-width:500px; 
		    min-height:400px; 
		    max-height:600px; 
		    
		    height:auto;
		    background: #fff;  
		    border: 1px solid #ccc;  
		/*    margin: -102px 0 0 -202px;  */
		    display: none !important;
		    z-index: 10001 
		}
		.show{ display: block !important;}
		
		.content-div{margin: 1% 2%;width: 96%;height: 98%;}
		.tan_close_div {text-align: right;min-height:10px;}
		.tan_close_div a{ float: right;font-size: 18px;color: #ccc;}
		
		
		
		.frame_div iframe{width: 100%;height: 100%;border:1px solid #ccc;min-height: 380px; }
		
		/*弹出层确认按钮*/
		.tan_btn_div{width: 100%;min-height: 40px;text-align: center;line-height:40px;}
		.tan_btn_div a:first-child{margin-right:15px;}
		.tan_btn_div a{padding:5px 10px;color:#fff;background-color:#36A7C4; }
		.tan_btn_div a:focus,.tan_btn_div a:active,.tan_btn_div a:hover{color:#fff; background-color: #0d638f;text-decoration: none;}

	</style>
<script type="text/javascript">
//查询操作
function  searchShi(param){
	 var data = {};
		$.each(param,function(i,v){
			data[v.name] = v.value;
		});
	jQuery("#grid-table").jqGrid("setGridParam",
	{
	       datatype:"json",
	       postData:data, //发送数据  
	       page:"1"
	}).trigger("reloadGrid");
		 
	   
	$(".ui_inner_tan").hide();
   	$(".ui_out_tan").hide();	 
}

$(function(){
	     orderStatusShow=[]; 

		 <c:forEach items="${status}" var="listStatus"> 
		     var keyL ='${listStatus.key}';
		     orderStatusShow[keyL]='${listStatus.value}';
		 </c:forEach> 	
})
</script>
</head>
<body>

 <div id="outer" class="outer-div" >  
  </div>  
  <div id="inner" class="inner-div" > 
  
  <div class="content-div">
	  <div class="tan_close_div">
	     <a href="javascript:void(0);"  onclick="javascript:close_tan()" >×</a>
	  </div>
	  
	  <!-- 加载iframe -->
	  <div class="frame_div" id="frame_div">
	  
	   <iframe  name="task_frame" id="task_frame">
	   
	
	   
	   </iframe>
	   
	  </div>
      <!-- end 加载iframe -->
      
	  <div class="tan_btn_div">
	    <a href="javascript:void(0);" class="assignee_ok" onclick="javascript:assignee_ok()"> 审核通过</a>
	    <a href="javascript:void(0);" class="assignee_cancel" onclick="javascript:close_tan()"> 审核驳回</a>
	  </div>
 
  </div>
 
 
 </div>

	
	
    <!-- begin 查询 -->
    
     <div class="ui-widget ui-widget-content ui-corner-all ui-jqdialog jqmID1 ui_inner_tan" id="portlet-config-query" dir="ltr" tabindex="-1" role="dialog" aria-labelledby="edithdgrid-table" aria-hidden="false" >
      <div class="ui-jqdialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix"  style="cursor: move;">
	   <span class="ui-jqdialog-title" style="float: left;">查询</span>
	   <a href="javascript:void(0)" class="cancel ui-jqdialog-titlebar-close ui-corner-all" style="right: 0.3em;">
	    <span class="ui-icon ui-icon-closethick"></span>
	   </a>
   </div>
   <div class="ui-jqdialog-content ui-widget-content" id="editcntgrid-table"><div>
   <div class="modal-body">
   <form name="form" id="form" class="FormGrid ui_inner_form" method="post" >
   
           <div class="control-group">
							<div class="controls">
							<input id="id" name="id" type="hidden" />

							<div class="input-prepend">
							  <span class="add-on"><%=IPriceConstants.TABLE_COLUMN_DISPLAY.get("productId")%></span>						<input type="text" class="m-wrap"  name="productId" />
<span class="choose_ref"  onclick="javascript:getNewReference('<%=request.getContextPath()%>/product/reference?referenceInputType=radio','form.productId,form.productName');">选择</span>
							</div>

							<div class="input-prepend">
							  <span class="add-on"><%=IPriceConstants.TABLE_COLUMN_DISPLAY.get("productName")%></span><input class="m-wrap" name="productName"  type="text"  						maxLength="200" />
							</div>

							<div class="input-prepend">
							  <span class="add-on"><%=IPriceConstants.TABLE_COLUMN_DISPLAY.get("startTime")%></span><input name="startTime"  class="m-wrap m-ctrl-medium date-picker" readonly size="16" type="text" value="" inputName="<%=IPriceConstants.TABLE_COLUMN_DISPLAY.get("startTime")%>" />
							</div>

							<div class="input-prepend">
							  <span class="add-on"><%=IPriceConstants.TABLE_COLUMN_DISPLAY.get("endTime")%></span><input name="endTime"  class="m-wrap m-ctrl-medium date-picker" readonly size="16" type="text" value="" inputName="<%=IPriceConstants.TABLE_COLUMN_DISPLAY.get("endTime")%>" />
							</div>

							<div class="input-prepend">
							  <span class="add-on"><%=IPriceConstants.TABLE_COLUMN_DISPLAY.get("price")%></span><input class="m-wrap" name="price"  type="text"  						maxLength="19" />
							</div>

							<div class="input-prepend" style="height:44px">
							  <span class="add-on"><%=IPriceConstants.TABLE_COLUMN_DISPLAY.get("status")%></span><%=RmJspHelper.getSelectField("status", -1, RmGlobalReference.get(ISystemConstant.DICTIONARY_PRICE_STATUS), "", "inputName='" + IPriceConstants.TABLE_COLUMN_DISPLAY.get("status") + "'  ", true) %>							</div>


							</div>
			 </div>
     
     </form>
     </div>
     
     <div class="EditTable operate_div" >
       <a href="javascript:void(0)" id="sData" class="fm-button ui-state-default ui-corner-all fm-button-icon-left" onclick="javascript:searchShi($(form).serializeArray());">
       <i class="icon-search"></i>
           查询</a>
       <a href="javascript:void(0)" id="cData" class="cancel fm-button ui-state-default ui-corner-all fm-button-icon-left">
      <i class="icon-remove"></i> 
              取消</a>
     </div>
   
     </div></div>
     
     </div>
     
    
    
    <!-- end 查询 -->

						<ul class="breadcrumb">
							<li>
								<i class="icon-home home-icon"></i>
								<a href="<%=request.getContextPath()%>/?pcode=100112&childSource=ch0code">首页</a>
							</li>

							<li class="active">执行价格管理</li>
						</ul><!-- .breadcrumb -->
						<%--
						<div class="nav-search" id="nav-search">
							<form class="form-search">
								<span class="input-icon">
									<input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
									<i class="icon-search nav-search-icon"></i>
								</span>
							</form>
						</div><!-- #nav-search -->
						 --%>
					</div>

					<div class="page-content">
						<!-- <div class="page-header">
							<h1>
								价格管理
								<small>
									<i class="icon-double-angle-right"></i>
									数据列表展示
								</small>
							</h1>
						</div> page-header -->

						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->

								<table id="grid-table"></table>

								<div id="grid-pager"></div>

								<script type="text/javascript">
									var $path_base = "/";//this will be used in gritter alerts containing images
								</script>

								<!-- PAGE CONTENT ENDS -->
							</div><!-- /.col -->
						</div><!-- /.row -->
					</div><!-- /.page-content -->
				</div><!-- /.main-content -->



			</div><!-- /.main-container-inner -->

		
		</div><!-- /.main-container -->

		<script type="text/javascript">
			//var grid_data = ${grid_data};	
		
			jQuery(function($) {
				if('${message}'!=''){
					alert('${message}');
				}
				var grid_selector = "#grid-table";
				var pager_selector = "#grid-pager";

				jQuery(grid_selector).jqGrid({
					//direction: "rtl",
					
					url: getRootPath()+'/frontflowdef/ajaxListTask?${queryString}',
					datatype: "json",
				    mtype: 'POST',  
					height: "100%",
					colNames:[
'任务名称'
,'发起人'
,'创建时间'
,'操作'

],
					colModel:[
			{name:'taskName',index:'taskName', width:90,editable: true,editoptions:{size:"20",maxLength:"200"}},
			{name:'initiator',index:'initiator', width:90,editable: true,editoptions:{size:"20",maxLength:"19"}},
			{name:'taskCreateTime',index:'taskCreateTime', width:90,editable: true,editoptions:{size:"20",maxLength:"1"}},
			{name:'doubleParameter',index:'doubleParameter',width:90, editable:true, sorttype:"date",formatter:splicedUrlTask},
					], 
			        //shrinkToFit:false,//不随列数量改变列宽度
					viewrecords : true,
					rownumbers:true,
					rowNum:15,
					rowList:[15,30],
					pager : pager_selector,
					sortname : 'id',//初始化的时候排序的字段
					sortorder : "desc",//排序方式,可选desc,asc
					altRows: true,
					//toppager: true,
					
					multiselect: true,
					//multikey: "ctrlKey",
			        multiboxonly: true,
			
					loadComplete : function() {
						var table = this;
						setTimeout(function(){
							
							
							updateActionIcons(table);
							updatePagerIcons(table);
							enableTooltips(table);
						}, 0);
					},
			
					editurl: getRootPath()+'/price/update',//nothing is saved
					caption: "价格管理列表展示",
					autowidth: true
			
				});
				
				//拼接url
				function splicedUrlTask(cellvalue, options, cell){
					var arr = cellvalue.split("@");
					if(arr[1]=='' || arr[1]=='null'){
						var url = '<a href="${pageContext.request.contextPath}/frontflowdef/claim/'+arr[0]+'" >签收</a>';
					}else{
						var url = '<a href="${pageContext.request.contextPath}/frontflowdef/taskShow?taskId='+arr[0]+'&formUrl='+arr[2]+'" >办理</a>';
						/* var url = '<a onclick="showTask(\''+arr[2]+'\')" href="#" >办理</a>'; */
					}
					return url;
				}
				
				//enable search/filter toolbar
				//jQuery(grid_selector).jqGrid('filterToolbar',{defaultSearch:true,stringResult:true})
			
				//enable datepicker
				function pickDate( cellvalue, options, cell ) {
					setTimeout(function(){
						$(cell) .find('input[type=text]')
								.datepicker({format:'yyyy-mm-dd' , autoclose:true}); 
					}, 0);
				}
			
			
				//navButtons
				jQuery(grid_selector).jqGrid('navGrid',pager_selector,
					{ 	//navbar options
						edit: false,
						editicon : 'icon-pencil blue',
						add: false,
						addicon : 'icon-plus-sign purple',
						del: false,
						delicon : 'icon-trash red',
						search: false,
						searchicon : 'icon-search orange',
						refresh: false,
						refreshicon : 'icon-refresh green',
						view: false,
						viewicon : 'icon-zoom-in grey',
					
					}
				)
				
				/*//新增
			   jQuery(grid_selector) .navButtonAdd(pager_selector,
					{ caption:"", buttonicon:"icon-plus-sign purple",
				      onClickButton: addShow, position:"last" }) ;
			
				//删除
				  jQuery(grid_selector) .navButtonAdd(pager_selector,
					{ caption:"", buttonicon:"icon-trash red",
				      onClickButton:deleteShow , 
				      position:"last" }) ;*/
				//修改
				  jQuery(grid_selector) .navButtonAdd(pager_selector,
					{ caption:"", buttonicon:"icon-pencil blue",
				      onClickButton:updateShow, 
				      position:"last" }) ;
				      
				//查询
				  jQuery(grid_selector) .navButtonAdd(pager_selector,
					{ caption:"", buttonicon:"icon-search orange",
				      onClickButton:search_div , 
				      position:"last" }) ;
				
			     //新增弹出
			     
				 function addShow(){
			    	 
			    	 $(".ui_out_tan").show();
			    	 $("#add_form").show();
					 
				 }
			     
			     //  修改弹出
			     function updateShow(){
			    	 
			    	var checkedLen= $(".cbox:checked").length;
			    	if(checkedLen==0){
			    		
			    		alert("请至少选择一条数据！");
			    		return false;
			    	}
                    if(checkedLen>1){
			    		
			    		alert("最多只能选择一条数据！");
			    		return false;
			    	}
                    var pointer=$(".cbox:checked").parents("tr");
                    var updateDate=$(pointer).attr("id");
                    var rowData = $("#grid-table").jqGrid('getRowData',updateDate);
					var status=rowData.status;
					if(status=='已审核通过'){
						alert("已审核通过不能修改!");
						return false;
					}
                    $.ajax({
                        type: "POST",
                        url: "<%=request.getContextPath()%>/price/get/" + updateDate+"/"+new Date(),
                        dataType: "json",
                        async:false , //false为同步
                        success: function(data,status) {
                	   	   if(data.status=="0"){
                	   	       alert(data.message);
                	   	   }else{
                      $("#portlet-config-edit").find("input[id=id]").val(data.bean.id);
                      $("#portlet-config-edit").find("input[id=productId]").val(data.bean.productId);
                      $("#portlet-config-edit").find("input[id=productName]").val(data.bean.productName);
                      $("#portlet-config-edit").find("input[id=price]").val(data.bean.price);
                      $("#portlet-config-edit").find("input[id=startTime]").val(data.bean.startTime);
                      $("#portlet-config-edit").find("input[id=endTime]").val(data.bean.endTime);
                      $("#portlet-config-edit").find("input[id=status]").val(data.bean.status);
                	   	   }
                       },
                       error:function(xhr,s1,s2){
                       	var message = xhr.responseText;
               			eval("var json = "+message);
               			if($.trim(json.error).length==0){
               				alert('数据异常,请刷新页面重试');
               			}else{
               				alert(json.error);
               			}
                  	   }
                    });
			    	 $(".ui_out_tan").show();
                     $("#portlet-config-edit").show();
			    	 
			     }
			     
			     //删除弹出
			     function deleteShow (){
			    	 
			    	 var checkedLen= $(".cbox:checked").length;
				    	if(checkedLen==0){
				    		
				    		alert("请至少选择一条数据！");
				    		return false;
				    	}
				    	$(".ui_out_tan").show();
				        $("#portlet-config-delete").show(); 
				    	
			    	 
			     }
                //查询层
			     
			     function search_div(){
			    	 $(".ui_out_tan").show();
			    	 $("#portlet-config-query").show();
			     }
			     
			     
			 
			     
			     
			     
				//unlike navButtons icons, action icons in rows seem to be hard-coded
				//you can change them like this in here if you want
				function updateActionIcons(table) {
					/**
					var replacement = 
					{
						'ui-icon-pencil' : 'icon-pencil blue',
						'ui-icon-trash' : 'icon-trash red',
						'ui-icon-disk' : 'icon-ok green',
						'ui-icon-cancel' : 'icon-remove red'
					};
					$(table).find('.ui-pg-div span.ui-icon').each(function(){
						var icon = $(this);
						var $class = $.trim(icon.attr('class').replace('ui-icon', ''));
						if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
					})
					*/
				}
				
				//replace icons with FontAwesome icons like above
				function updatePagerIcons(table) {
					var replacement = 
					{
						'ui-icon-seek-first' : 'icon-double-angle-left bigger-140',
						'ui-icon-seek-prev' : 'icon-angle-left bigger-140',
						'ui-icon-seek-next' : 'icon-angle-right bigger-140',
						'ui-icon-seek-end' : 'icon-double-angle-right bigger-140'
					};
					$('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function(){
						var icon = $(this);
						var $class = $.trim(icon.attr('class').replace('ui-icon', ''));
						
						if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
					})
				}
			
				function enableTooltips(table) {
					$('.navtable .ui-pg-button').tooltip({container:'body'});
					$(table).find('.ui-pg-div').tooltip({container:'body'});
				}
			
				//var selr = jQuery(grid_selector).jqGrid('getGridParam','selrow');
				function orderStatus(cellvalue, options, cell){

					return orderStatusShow[cellvalue];
				} 
			
			});
			
			
			//显示弹出层
			function showTask(formUrl){
				jQuery("#frame_div").find("iframe").prop("src","${pageContext.request.contextPath }"+formUrl);
				jQuery("#outer").addClass("show");
				jQuery("#inner").addClass("show");
			}
			//关闭弹出层
			function close_tan(){
				
				jQuery("#outer").hide().removeClass("show");
				jQuery("#inner").hide().removeClass("show");
				
				jQuery("#inner").removeClass("inner-div-dept");
				jQuery("#frame_div").removeClass("frame_div_dept");
				
				jQuery("#frame_div").find("iframe").html("");
				jQuery("#frame_div").find("iframe").prop("scr","");
			}

			
		</script>
	</body>
</html>
